<template>
  <div class="con">
    <el-container>
      <!-- <el-header style="padding:0;height: 56px;">
        <headbox ref="mychild"></headbox>
      </el-header>-->
      <el-container>
        <!-- <el-aside  style="width:200px;background-color:#393D49;">
          <left></left>
        </el-aside>-->
        <el-container>
          <el-main style="padding:0;">
            <!-- 放置内容区 -->
            <div class="contbox6_10" v-loading="listLoading">
              <!-- 机构列表 -->
              <p class="titlelist6_10">
                结算信息
                <span style="color: #999;">&nbsp;&nbsp;/&nbsp;&nbsp;</span>提现
              </p>
              <div class="content">
              <p class="sizes">提现</p>
              <el-divider></el-divider>
              <el-form
                :model="ruleForm"
                :hide-required-asterisk="true"
                ref="ruleForm"
                label-width="110px"
                class="demo-ruleForm"
              >
                <el-form-item
                  label-width="110px"
                  label="账户号码："
                  prop="password"
                >{{ruleForm.withdrawBank}}</el-form-item>
                <el-form-item label-width="110px" label="账户余额：" prop="password">{{ruleForm.avail}}元</el-form-item>
                <el-form-item
                  label-width="140px"
                  label="银行卡代付手续费："
                  prop="password"
                >{{ruleForm.behalfPayCost}}元/笔</el-form-item>
                <el-form-item
                  label-width="140px"
                  label="银行卡代付手续费："
                  prop="password"
                >{{ruleForm.payCost}}%</el-form-item>
                <!-- <el-form-item label-width="110px" label="提现手续费：" prop="password">
                  {{ruleForm.payCost}}%
                </el-form-item>-->
                <!-- <el-form-item label-width="110px" label="单笔通道成本：" prop="password">
                  {{ruleForm.behalfPayCost}}元
                </el-form-item>-->

                <el-form-item label-width="110px" label="提现金额：" prop="password">
                  <el-input
                    class="ipt"
                    type="number"
                    v-model="cashOutAmount"
                    placeholder="请输入本次提现金额"
                  ></el-input>
                  <span>元</span>
                </el-form-item>

                <p class="itemp">
                  <i class="el-icon-document-checked"></i>提现金额预计1-3个工作日到账！如签约提供发票，请尽快提供发票
                </p>

                <el-form-item style="margin-left:40%">
                  <el-button type="primary" @click="submitForm('ruleForm')">提交</el-button>
                </el-form-item>
              </el-form>
            </div></div>
          </el-main>
          <!-- <el-footer style="padding:0;">
            <footerbox></footerbox>
          </el-footer>-->
        </el-container>
      </el-container>
    </el-container>
  </div>
</template>

<script>
// import left from "../../left";
// import footerbox from "../../footer.vue";
// import headbox from "../../head.vue";
import https from "../../plugins/https";
export default {
  data() {
    return {
      ruleForm: {
      },
      listLoading: false,
      cashOutAmount: "",
    };
  },
  components: {
  },
  mounted() {
    this.withdrawForms();
  },
  methods: {
    withdrawForms() {
      this.listLoading = true;
      https
        .withdrawForm({ officeUid: localStorage.getItem("uid") })
        .then((res) => {
          if (res.data.code !== "0000") {
            layer.open({
              content: res.data.msg,
              skin: "msg",
              time:  2, //1秒后自动关闭
            });
            // this.$notify({
            //   title: "错误",
            //   message: res.data.msg,
            //   type: "error",
            // });
            this.listLoading = false;
            return;
          }
          this.ruleForm = res.data.dowithdrawReponse;
          this.listLoading = false;
        });
    },
    // 提交
    submitForm(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          if (this.cashOutAmount == "")
            return this.$notify({
              title: "错误",
              message: "请输入本次提现金额",
              type: "error",
            });
          if (+this.cashOutAmount < 1)
            return layer.open({
              content: "请输入正确提现金额",
              skin: "msg",
              time:  2, //1秒后自动关闭
            });
            // this.$notify({
            //   title: "错误",
            //   message: ,
            //   type: "error",
            // });
          this.listLoading = true;
          let pl = {
            officeUid: localStorage.getItem("uid"),
            cashOutAmount: this.cashOutAmount,
          };
          https.subWithdrawForm(pl).then((res) => {
            if (res.data.code !== "0000") {
              layer.open({
              content: res.data.msg,
              skin: "msg",
              time:  2, //1秒后自动关闭
            });
              // this.$notify({
              //   title: "错误",
              //   message: res.data.msg,
              //   type: "error",
              // });
              this.listLoading = false;
              return;
            }
            // this.$notify({
            //   title: "成功",
            //   message: res.data.msg,
            //   type: "success",
            // });
             layer.open({
              content: res.data.msg,
              skin: "msg",
              time:  2, //1秒后自动关闭
            });
            this.cashOutAmount = "";
            this.withdrawForms();
            this.listLoading = false;
          });
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },
  },
};
</script>

<style scoped>
.content{
  min-width: calc(100% - 40px)
}
.el-form-item{
  width:450px
}
.l20 {
  margin-left: 20px;
}
.con{
  position: relative;
}
.Moneystyle {
  font-size: 13px;
}
.itemp {
  font-size: 11px;
  margin-bottom: 30px;
  float: left;
  color: #999;
}
.ipt {
  /* width: 300px; */
}
.sizes {
  font-size: 15px;
  margin-bottom: 20px;
  color: #999;
}
/* 单独样式 */
.contbox6_10 {
  width: 100%;
  /*  height: 87.5vh; */
  overflow-x: auto;
  box-sizing: border-box;
  float: left;
}
.titlelist6_10 {
  width: 100%;
  /* float: left; */
  font-size: 16px;
  color: #222;
  /* margin-top: 40px; */
}
.el-icon-document-checked {
  position: relative;
  top: 4px;
  display: inline-block;
  color: #409eff;
  font-size: 25px;
  margin-right: 5px;
}
</style>

